<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:sec="http://www.springframework.org/security/facelets/tags"
                xmlns:p="http://primefaces.org/ui"
                template="/pages/_template.xhtml">
    <ui:define name="centro">

        <div id="centro" >
            <div >

                <!--            Inicializando o login-->
                <h:form id="loginForm" prependId="false" >
                    <p:dialog header="SIAGEFI (Sistema de apoio a gestão financeira)" visible="true" closable="false" draggable="false" resizable="false" width="460">

                        <div style="float: right;">
                            <h:panelGrid columns="1">
                                <p:graphicImage value="/resources/imagens/icon-acesso.png" style="width: 150px; height: 140px;"/> 
                            </h:panelGrid>
                        </div>
                        <p:messages id="errorLogin"  >
                            #{param.erro}
                        </p:messages>

                      <p:focus for="j_username"/>

                        <!--                    Aqui está o comando para chamar o spring security-->
                        <p:panelGrid columns="1">
                            <h:outputLabel value="Usuario" for="j_username" />
                            <p:inputText id="j_username" value="#{loginBean.userName}" 
                                         required="true" requiredMessage="Informe o usuário!">
                            </p:inputText>

                            <h:outputLabel value="Senha" for="j_password"/>
                            <p:password id="j_password" value="#{loginBean.password}" feedback="false"
                                        required="true" requiredMessage="Informe a senha!">
                            </p:password>

                            <p:commandButton action="#{loginBean.doLogin()}" value="Acesso" ajax="false" icon="ui-icon-key"/>
                        </p:panelGrid>

                    </p:dialog>
                    <!--                Finalização do login com spring security-->

                </h:form>
            </div>
        </div>
    </ui:define>

</ui:composition>
